<head>
	<meta charset="utf-8" />
	<meta http-equiv="X-UA-Compatible" content="IE=edge">
	<meta http-equiv="Permissions-Policy" content="interest-cohort=()"/>
	{{- $title := ( .Title ) -}}
	{{- $siteTitle := ( .Site.Title ) -}}
	{{- if .IsHome -}}
	<title>{{ $siteTitle }} | Home </title>
	{{- else -}}
	<title>{{ $title }} - {{ $siteTitle }}</title>
	{{- end -}}

	{{- if isset .Site.Params "favicon" -}}
	<link rel="icon" type="image/png" href={{ .Site.BaseURL }}{{ .Site.Params.favicon }} />
	{{- end -}}
	
	{{ if (in (string .Permalink) "/homepage/")}} <meta http-equiv="refresh" content="1; URL={{ .Site.BaseURL}}" /> {{ end }}

	{{ if .Params.externalLink }} <meta http-equiv="refresh" content="3; URL={{ .Params.externalLink}}" /> {{ end }}

	<meta name="viewport" content="width=device-width, initial-scale=1">
	<meta name="description" content="{{ with .Description }}{{ . }}{{ else }}{{if .IsPage}}{{ .Summary }}{{ else }}{{ with .Site.Params.description }}{{ . }}{{ end }}{{ end }}{{ end }}" />
	<meta property="og:image" content="{{ .Site.BaseURL }}{{ .Site.Params.og_image }}"/>
	{{ with .OutputFormats.Get "rss" -}}
	{{ printf `<link rel="%s" type="%s" href="%s" title="%s" />` .Rel .MediaType.Type .Permalink $.Site.Title | safeHTML }}
	{{ end -}}

	{{- template "_internal/opengraph.html" . -}}
	{{- template "_internal/twitter_cards.html" . -}}
	{{ if and (isset .Site.Params "social") (.Site.Params.useCDN | default false) -}}
		<script src="https://unpkg.com/lucide@latest"></script>
	{{- else if (isset .Site.Params "social") -}}
		<script src="{{ .Site.BaseURL }}js/lucide.min.js"></script>
	{{ end }}
	{{ if .Site.Params.useCDN | default false -}}
        <link href="https://fonts.googleapis.com/css2?family=IBM+Plex+Mono:ital,wght@1,500&display=swap" rel="stylesheet">
        <link href="https://fonts.googleapis.com/css2?family=Fira+Sans&display=swap" rel="stylesheet">
        <link href="https://fonts.googleapis.com/css?family=Roboto+Mono" rel="stylesheet">
	{{- else -}}
	{{ $fontstyle := resources.Get "css/fonts.css" | minify | fingerprint }}
        <link href="{{ $fontstyle.Permalink }}" rel="stylesheet">
	{{ end }}

	{{ $style := resources.Get "css/main.css" | minify | fingerprint }}
	<link rel="stylesheet" type="text/css" media="screen" href="{{ $style.Permalink }}" />

	{{- if or (eq .Site.Params.mode "auto") (eq .Site.Params.mode "dark") -}}
		{{ $darkstyle := resources.Get "css/dark.css" | minify | fingerprint }}
		<link rel="stylesheet" type="text/css" href="{{ $darkstyle.Permalink }}" {{ if eq .Site.Params.mode "auto" }}media="(prefers-color-scheme: dark)"{{ end }} />
	{{ end }}

	{{- if or (eq .Site.Params.mode "auto") (eq .Site.Params.mode "light") -}}
	{{ $darkstyle := resources.Get "css/dark.css" | minify | fingerprint }}
	<link disabled id="dark-mode-theme" rel="stylesheet" href="{{ $darkstyle.Permalink }}">
	{{ end }}

	<!-- fontawesome -->
	{{ $style := resources.Get "css/fontawesome/all.css" | minify | fingerprint }}
	<link rel="stylesheet" type="text/css" media="screen" href="{{ $style.Permalink }}" />

	<!-- Custom CSS style get applied last -->
	{{- if isset .Site.Params "customcss" }}
		{{ range .Site.Params.customCSS }}
		{{ $customstyle := resources.Get . | minify | fingerprint }}
		<link rel="stylesheet" type="text/css" href="{{ $customstyle.Permalink }}">
		{{ end }}
	{{- end -}}
	{{- range .Site.Params.customJS }}
	{{- if or (hasPrefix . "http://") (hasPrefix . "https://") }}
	<script src="{{ . }}"></script>
	{{- else }}
	<script src="{{ $.Site.BaseURL }}{{ . }}"></script>
	{{- end }}
	{{- end }}

	{{ if ( .Params.math | default false )}}
	  {{ partial "katex.html" . }}
	{{ end }}

	{{ if not .Site.IsServer }}
	  <!-- Global site tag (gtag.js) - Google Analytics -->
	  <script async src="https://www.googletagmanager.com/gtag/js?id={{ .Site.GoogleAnalytics }}"></script>
	  <script>
	    window.dataLayer = window.dataLayer || [];
	    function gtag(){dataLayer.push(arguments);}
	    gtag('js', new Date());
	    gtag('config', '{{ .Site.GoogleAnalytics }}');
	  </script>
	{{ end }}

	<!-- webmention -->
	<link rel="webmention" href="https://webmention.io/robbinespu.gitlab.io/webmention" />
	<link rel="pingback" href="https://webmention.io/robbinespu.gitlab.io/xmlrpc" />

</head>
